﻿using System.Diagnostics.Contracts;

namespace Microsoft.Owin
{
  public static class ReadableStringCollectionExtensions
  {
    public static decimal? TryParseDecimal(this IReadableStringCollection collection, string key)
    {
      Contract.Requires(collection != null);
      Contract.Requires(key != null);

      decimal i;
      return decimal.TryParse(collection[key], out i) ? i : (decimal?)null;
    }
  }
}